<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*
        入栈 push
        出栈 pop
        peek         获取栈顶 peek
        isEmpty      判断栈是否为空 
        size         可以看栈中有多少个值 
        */
       function Stack(){
           this.items = [];
       }
       Stack.prototype.push = function(val){
           this.items.push(val)
       }
       Stack.prototype.pop = function(){
           var res = this.items.pop()
           return  res ;
       }

       Stack.prototype.peek= function(val){
           return this.items[this.items.length-1]
       }
       var s = new Stack();
       s.push(2);
       s.push(3);
       console.log(s.items);[2,3]
       console.log(s.pop())//3 出栈
    </script>
</body>
</html>